package com.yanqu.road.server.cmd.zhaoshang;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.zhaoshang.warp.ZsAdditionInfos;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.zhaoshang.ZhaoShangProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.zhaoshang.ZsMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C2_ZHAO_SHANG_USER_INFO_SYNC, desc = "玩家基本信息同步")
public class ZsPlayerBaseInfoSyncCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ZhaoShangProto.CrossZsPlayBaseInfoSyncMsg syncMsg = ZhaoShangProto.CrossZsPlayBaseInfoSyncMsg.parseFrom(packet.getBytes());
        ZsAdditionInfos additionInfos = new ZsAdditionInfos();
        additionInfos.setTitleAddition(syncMsg.getTitleAddition());
        additionInfos.setDecorationAddition(syncMsg.getAddition());
        additionInfos.setDecorationClass(syncMsg.getDecorationClass());
        additionInfos.setDecorationOverTime(syncMsg.getDecorationOverTime());
        UserBaseInfo userBaseInfo = PlayerBasePb.parseToUserBaseInfo(syncMsg.getUserBaeInfo());
        ZsMgr.syncUserBaseInfo(serverId, userBaseInfo, packet.getPlayerId(), additionInfos);
    }

    @Override
    public void sendData() {

    }
}
